﻿using System;
using System.Collections;


namespace Chess_Model
{

    public abstract class Piece
    {

        // Constants to distinguish two teams
        public const int WHITE = 0;
        public const int BLACK = 1;

        // Player (WHITE OR BLACK)
        protected int player;

        // Position of the piece
        protected Position pos;


        // Return position
        public Position getCurrentPosition()
        {
            return new Position(pos.x, pos.y);
        }


        // Return the piece color
        public int getPlayer()
        {
            return player;
        }


        // Moves to new position, regardless of legality of the new position
        // Position is assumed correct.
        // Return false if position is out of range or null
        public virtual bool moveTo(Position newPos)
        {
            if (newPos == null || !ChessUtilities.isInRange(newPos.x, newPos.y))
                return false;

            pos.x = newPos.x;
            pos.y = newPos.y;

            return true;
        }


        // Generates a list of new legal positions from the current position
        // regardless of the other pieces' positions
        public abstract ArrayList getNextLegalMoves();

        // String representation of a piece
        public abstract String toString();

        // are we on the same team?
        public bool isSameTeam(Piece p)
        {
            return p.player == this.player;
        }

     

    }

}
